package com.hubu.parking.controller;

import cn.hutool.core.util.RandomUtil;
import com.hubu.parking.entity.park.Notice;
import com.hubu.parking.entity.park.User;
import com.hubu.parking.service.NoticeService;
import com.hubu.parking.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.List;

@SpringBootTest(classes = com.hubu.parking.ParkingApplication.class)
public class testNotice {

    @Resource
    private UserService userService;

    @Resource
    private NoticeService noticeService;

    @Test
    public void addNotice() {
        for (int i = 0; i < 50; i++) {
            Notice notice = new Notice();
            notice.setTitle("title-" + RandomUtil.randomString(4));
            notice.setContent(RandomUtil.randomString(10));
            List<User> userList = userService.listAllAdmin();
            notice.setCreatedBy(userList.get(RandomUtil.randomInt(0, userList.size())).getId());
            noticeService.save(notice);
        }
    }
}
